require 'crawler/crawler'

module Crawler
  
  class BrightkiteCrawler < Crawler
    
    public
    
    def initialize(args={})
      super args
      @curl.follow_location = true
      @curl.max_redirects = -1
    end
    
    def service_name
      "brightkite"
    end
    
    def crawl_table
      BrightkiteCrawl
    end
    
    protected
    
    def crawl(c)
      request = "http://brightkite.com/people/#{c.service.username_on_service}.json?dataset=profile,stats"
      @curl.url = request
      @curl.http_get
      c.body = @curl.body_str
      c.status = @curl.response_code
      @curl.response_code == 200
    end
    
    def has_crawl?(s)
      !s.brightkite_crawl.nil?
    end
    
  end
  
end # module Crawler 